﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AlterAnnouncement.ascx.cs" Inherits="AlterAnnouncement" %>
<h3>Alter Announcement</h3>

<asp:Label ID="lblConfirm" runat="server" Text="" Class="confirmLabel"></asp:Label>
<br />
<asp:Label ID="lblSearch"  runat="server" Text="Search by Event Title or Description"></asp:Label>
<br />
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" onclick="btnSearch_Click" />
&nbsp;
<asp:Button ID="btnNew" runat="server" Text="New Announcement" onclick="btnNew_Click" />
<br />
<br />


<asp:GridView ID="GridView_Announcement" runat="server" AllowPaging="True" 
    AutoGenerateColumns="False" DataKeyNames="AnnouncementID,PersonID1" 
    DataSourceID="SqlDataSource_grid" AllowSorting="True" 
    onselectedindexchanged="GridView_Announcement_SelectedIndexChanged">
    <Columns>
        <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="DatePosted" HeaderText="DatePosted" 
            SortExpression="DatePosted" />
        <asp:CommandField ShowDeleteButton="False" SelectText="Edit" 
            ShowSelectButton="True" />
    </Columns>
</asp:GridView>

<br />
<br />

<asp:SqlDataSource ID="SqlDataSource_grid" runat="server" 
    ConnectionString="<%$ ConnectionStrings:BPI_LibraryConnectionString %>" 
    SelectCommand="usp_ANNOUNCEMENT_LibrarianViewGrid" 
    SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="txtSearch" Name="Value" PropertyName="Text" 
            Type="String" />
        <asp:QueryStringParameter Name="libraryId" QueryStringField="id" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource_selected" runat="server" 
    ConnectionString="<%$ ConnectionStrings:BPI_LibraryConnectionString %>" 
    SelectCommand="usp_ANNOUNCEMENT_LibrarianViewGrid" 
    SelectCommandType="StoredProcedure" 
    InsertCommand="usp_ANNOUNCEMENT_LibrarianInsert" 
    InsertCommandType="StoredProcedure" 
    UpdateCommand="usp_ANNOUNCEMENT_LibrarianUpdate" 
    UpdateCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="GridView_Announcement" Name="Value" PropertyName="SelectedValue" 
            Type="String" />
        <asp:QueryStringParameter Name="libraryId" QueryStringField="id" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="AnnouncementID" Type="Int32" />
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="DatePosted" Type="DateTime" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="DatePosted" Type="DateTime" />
        <asp:Parameter Name="PersonID" DefaultValue="100002" Type="Int32" />
        <asp:QueryStringParameter Name="libraryId" QueryStringField="id" Type="Int32" />
    </InsertParameters>
</asp:SqlDataSource>

<%--<asp:SqlDataSource ID="SqlDataSource_detailView" runat="server" 
    ConnectionString="<%$ ConnectionStrings:BPI_LibraryConnectionString %>" 
    SelectCommand="SELECT * FROM [ANNOUNCEMENT] WHERE ([AnnouncementID] = @AnnouncementID)" 
    UpdateCommand="UPDATE ANNOUNCEMENT SET PersonID = @PersonID, Title = @Title, Description = @Description, DatePosted = @DatePosted, LibraryID = @LibraryID WHERE (AnnouncementID = @AnnouncementId)">
    <SelectParameters>
        <asp:ControlParameter ControlID="GridView_Announcement" Name="AnnouncementID" 
            PropertyName="SelectedValue" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="PersonID" />
        <asp:Parameter Name="Title" />
        <asp:Parameter Name="Description" />
        <asp:Parameter Name="DatePosted" />
        <asp:Parameter Name="LibraryID" />
        <asp:Parameter Name="AnnouncementId" />
    </UpdateParameters>
</asp:SqlDataSource>
--%>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
    DataKeyNames="AnnouncementID" DataSourceID="SqlDataSource_selected" 
    Height="50px" Width="400px"  
    OnItemUpdating="DetailsView1_onItemUpdating"
    OnItemInserting="DetailsView1_onItemInserting">
    <Fields>
        
        <%--Title--%>
        <asp:TemplateField HeaderText="Title" SortExpression="Title">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>' Width="300" 
                Height="50" TextMode="MultiLine" ></asp:TextBox>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>' Width="300" 
                Height="50" TextMode="MultiLine" ></asp:TextBox>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Description" SortExpression="Description">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>' Width="300" 
                Height="100" TextMode="MultiLine" ></asp:TextBox>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>' Width="300" 
                Height="100" TextMode="MultiLine" ></asp:TextBox>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Date">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("DatePosted") %>'></asp:TextBox>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("DatePosted") %>'></asp:TextBox>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label3" runat="server" Text='<%# Bind("DatePosted") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
    </Fields>
</asp:DetailsView>




